package com.Adapters.Items;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import com.Animations.AnimUtil;
import com.Animations.AnimUtil.AnimationCompleted;
import com.activities.DefaultFunctions;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.shareup.R;
import com.utils.AppConstant;


public class ItemPostADV implements ItemPost {

    private Context context;

    private ViewHolder holder;

    private final LayoutInflater inflater;

    class ViewHolder {

        public AdView ad;

        public LinearLayout adLayout;
    }

    public ItemPostADV(LayoutInflater inflater, DefaultFunctions main) {

        super();
        this.inflater = inflater;
        this.context = main.getParentActivity();

    }

    /*
     * Show the animation of PostIn in AnimationUtil
     * @see com.Adapters.Items.ItemPost#AnimateIn()
     */
    @Override
    public void AnimateIn() {

        AnimUtil.animateFadeIn(holder.ad);
    }

    /*
     * Show the animation of PostOut in AnimationUtil
     * @see com.Adapters.Items.ItemPost#AnimateOut()
     */
    @Override
    public void AnimateOut(AnimationCompleted callback) {

        AnimUtil.animateFadeOut(holder.ad, callback);
    }

    /*
     * (non-Javadoc)
     * @see com.Adapters.Items.ItemPost#clearAnimatonList()
     */
    @Override
    public void clearAnimatonList() {

    }

    /*
     * (non-Javadoc)
     * @see com.Adapters.Items.ItemPost#delete()
     */
    @Override
    public void delete() {

    }

    @Override
    public int getCommentsCount() {

        return 0;
    }

    @Override
    public int getLikesCount() {

        return 0;
    }

    @Override
    public int getPostId() {

        return AppConstant.ADID_LAYOUT++;
    }

    @Override
    public String getPublicationDate() {

        return "";
    }

    @Override
    public View getView(View convertView, int position) {

        View view = null;

        if (convertView == null) {

            ViewGroup viewGroup = (ViewGroup) inflater.inflate(R.layout.item_ad, null);
            holder = new ViewHolder();
            holder.ad = (AdView) viewGroup.findViewById(R.id.adView);

            viewGroup.setTag(holder);
            view = viewGroup;
            AdRequest.Builder bl = new AdRequest.Builder();

            holder.ad.loadAd(bl.build());

        }
        else {
            holder = (ViewHolder) convertView.getTag();
            view = convertView;
        }

        return view;
    }

    @Override
    public int getViewType() {

        return RowType.ADV.ordinal();
    }

    @Override
    public void setCommentsCount(int count) {

    }

    @Override
    public void setLikesCount(int count) {

    }

    @Override
    public void updatePublicationDate(String newDate) {

    }

    /*
     * (non-Javadoc)
     * @see com.Adapters.Items.ItemPost#getPosition()
     */
    @Override
    public int getPosition() {

        // TODO Auto-generated method stub
        return 0;
    }

}
